#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLibrary>
#include <QSqlQuery>
#include <QThread>
#include <QTimer>
#include <QNetworkRequest>
#include <QNetworkInterface>
#include <QNetworkInterface>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>

#include "dialog_cfdy.h"
#include "dialog_gh.h"
#include "dialog_gh_env.h"
#include "formdocapply.h"
#include "formdrugitems.h"
#include "form_drugquery.h"
#include "form_sk.h"
#include "form_tf.h"
#include "form_chagepassword.h"
#include "form_gzltj.h"
#include "threadyb.h"
#include "form_recipeacount.h"
#include "form_jcmlxz.h"
#include "form_xmdz.h"
#include "form_xxcx.h"
#include "form_jsdz.h"
#include "form_dzbl.h"
#include "form_ybhj.h"
#include "form_input.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    QThread thread;
    ThreadYb *ybBusiness;

    void ybSign();

protected:
     void closeEvent(QCloseEvent *event);

public slots:
    void reg_trigged();
    void exit_trigged();
    void data_trans_triggerd();
    void action_ghsz_trigged();
    void action_cfdy_trigged();
    void actionDocApply_trigged();
    void actionDrugItems_trigged();
    void action_drugQuery_trigged();
    void action_sk_trigged();
    void action_tf_trigged();
    void action_changePass_trigged();
    void action_gzltj_trigged();
    void action_cftj_trigged();
    void action_jcmlxz_trigged();
    void action_xmdz_trigged();
    void action_xxcx_trigged();
    void action_jsdz_trigged();
    void action_dzbl_trigged();
    void action_ybhj_trigged();
    void action_zdwh_trigged();
    void action_InOut_trigged();

    void handleInitial(const int, const QString, const QString );
    //void handleSignIn(const int, const QString );
    void updateTitle(); //定时，显示title
    void waitInitFinish();//定时，等待卡初始化完成
    void postRequestFinished(QNetworkReply *);

    void destroyWind( QString );

signals:
    void opThread(int, QString);    // 发送信号触发线程

private:
    Ui::MainWindow *ui;
    QLibrary lib;
    QSqlQuery qrm;
    QSqlQuery qro;
    QTimer *tm, *tm2;
    Dialog_cfdy * dlg_cfdy;     //处方打印
    Dialog_gh * dlg_gh;         //挂号
    Dialog_gh_env * dlg_gh_env; //挂号环境配置
    FormDocApply * formDocApply; //医生出诊安排
    FormDrugItems * formDrugItems; //在用药品品种定义管理
    FormDrugQuery * formDrugQuery;  //药品查询
    Form_sk * form_sk;  //收款
    Form_tf * form_tf;  //退费管理
    Form_chagePassword * changePassword;//修改口令
    Form_gzltj * gzltj;//收费工作量统计
    Form_recipeAcount *cftj;    //处方统计
    Form_jcmlxz * jcmlxz; //基础目录下载
    Form_xmdz * xmdz; //项目对照
    Form_xxcx * xxcx;//信息查询
    Form_jsdz * jsdz;//结算对账
    Form_dzbl * dzbl;//电子病历
    Form_ybhj * ybhj;//医保环境
    Form_input * iteminout;//特殊记账入出

    volatile bool httpFinished;
    volatile bool initFinished;
    QString currentInfno;
    bool ybSigned ;
    QNetworkReply * rpl ;
    QNetworkRequest request;
    QNetworkAccessManager* naManager;

    QString currentMsgid;

};
#endif // MAINWINDOW_H
